//
//  VKHisRecordCell.m
//  V-Learn
//
//  Created by liubo on 2019/1/11.
//  Copyright © 2019 yxk. All rights reserved.
//

#import "VKSysMessageCell.h"

@implementation VKSysMessageCell{
    UILabel *_contentLabel;
    UILabel *_timeLabel;
}

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    VKSysMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"VKSysMessageCell"];
    if (cell == nil) {
        cell = [[VKSysMessageCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"VKSysMessageCell"];
    }
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    return cell;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 点击cell的时候不要变色
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor cz_colorWithRed:244 green:244 blue:244];

        // 布局子控件
        [self autoLayout];
    }
    return self;
}

-(void)setModel:(VKMeMessageModel *)model{
    _model = model;
    _contentLabel.text = model.messageContent;
    _timeLabel.text = [NSString stringWithFormat:@"   %@   ",model.createDate];
}

- (void)autoLayout{
    
    UIView *topView = [[UIView alloc]init];
    topView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@23);
        make.centerX.equalTo(self.contentView);
        make.width.equalTo(@80);
        make.top.equalTo(@25);
    }];

    UIView *bgView = [[UIView alloc]init];
    [self.contentView addSubview:bgView];
    bgView.backgroundColor = [UIColor whiteColor];
    bgView.layer.cornerRadius = 6;
    bgView.layer.masksToBounds = YES;
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topView.mas_bottom).offset(15);
        make.right.mas_equalTo(-15);
        make.left.equalTo(@15);
        make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-10);
    }];

    UILabel *timeLabel = [[UILabel alloc]init];
    _timeLabel = timeLabel;
    timeLabel.backgroundColor = [UIColor cz_colorWithRed:221 green:221 blue:221];
    timeLabel.layer.cornerRadius = 6;
    timeLabel.layer.masksToBounds = YES;
    [self.contentView addSubview:timeLabel];
//    timeLabel.text = @"上午9:08";
    timeLabel.textColor = [UIColor whiteColor];
    timeLabel.font = [UIFont systemFontOfSize:13];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(topView);
        make.top.equalTo(@25);
    }];


    UILabel *contentLabel = [[UILabel alloc]init];
    _contentLabel = contentLabel;
    [self.contentView addSubview:contentLabel];
//    contentLabel.text = @"历史记录历史记录历史记录历史记录历史记录历史记录历史记录";
    contentLabel.numberOfLines = 0;
    contentLabel.textColor = [UIColor cz_colorWithRed:62 green:62 blue:62];
    contentLabel.font = [UIFont systemFontOfSize:15];
    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.mas_equalTo(bgView).offset(15);
        make.right.mas_equalTo(bgView).offset(-15);
        make.bottom.mas_equalTo(bgView.mas_bottom).offset(-15);
    }];
}

@end
